const getTime = () => {
    function getCurrentWeekDayTimestamps(nowTime) {
        const oneDayTime = 24 * 60 * 60 * 1000; // 一天的毫秒数
        const today = new Date(nowTime);
        let weekDay = today.getDay(); // 当前日期的星期几（0为星期日，1为星期一，以此类推）

        if (weekDay === 0) {
            weekDay = 7; // 将星期日（0）转换为7
        }

        const timestamps = [];

        for (let i = 0; i < 5; i++) {
            let targetTime = nowTime + (i - weekDay + 1) * oneDayTime;
            timestamps.push(targetTime);
        }

        return timestamps;
    }
    function getNextWeekDayTimestamps(nowTime) {
        const oneDayTime = 24 * 60 * 60 * 1000; // 一天的毫秒数
        const today = new Date(nowTime);
        let weekDay = today.getDay(); // 当前日期的星期几（0为星期日，1为星期一，以此类推）

        if (weekDay === 0) {
            weekDay = 7; // 将星期日（0）转换为7
        }

        const timestamps = [];

        for (let i = 0; i < 5; i++) {
            let targetTime = nowTime + (8 - weekDay + i) * oneDayTime;
            timestamps.push(targetTime);
        }

        return timestamps;
    }

    const formatTimestamp = (timestamp) => {
        const date = new Date(timestamp);
        const year = date.getFullYear();
        const month = String(date.getMonth() + 1).padStart(2, '0');
        const day = String(date.getDate()).padStart(2, '0');
        const dayOfWeek = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][date.getDay()]; // 获取中文形式的星期几
        const formattedDate = `${year}${month}${day}-${dayOfWeek}`;
        return formattedDate;
    }

    let nowTime = Date.now(); // 当前时间戳
    let currentWeekTimestamps = getCurrentWeekDayTimestamps(nowTime)
    const currentMondayTime = currentWeekTimestamps[0]; // 本周一的时间戳
    const currentTuesdayTime = currentWeekTimestamps[1]; // 本周二的时间戳
    const currentWednesdayTime = currentWeekTimestamps[2]; // 本周三的时间戳
    const currentThursdayTime = currentWeekTimestamps[3]; // 本周四的时间戳
    const currentFridayTime = currentWeekTimestamps[4]; // 本周五的时间戳

    let nextWeekTimestamps = getNextWeekDayTimestamps(nowTime); // 获取下周一到周五的时间戳
    let nextMondayTime = nextWeekTimestamps[0]; // 下周一的时间戳
    let nextTuesdayTime = nextWeekTimestamps[1]; // 下周二的时间戳
    let nextWednesdayTime = nextWeekTimestamps[2]; // 下周三的时间戳
    let nextThursdayTime = nextWeekTimestamps[3]; // 下周四的时间戳
    let nextFridayTime = nextWeekTimestamps[4]; // 下周五的时间戳

    const now1 = formatTimestamp(currentMondayTime)
    const now2 = formatTimestamp(currentTuesdayTime)
    const now3 = formatTimestamp(currentWednesdayTime)
    const now4 = formatTimestamp(currentThursdayTime)
    const now5 = formatTimestamp(currentFridayTime)

    const next1 = formatTimestamp(nextMondayTime)
    const next2 = formatTimestamp(nextTuesdayTime)
    const next3 = formatTimestamp(nextWednesdayTime)
    const next4 = formatTimestamp(nextThursdayTime)
    const next5 = formatTimestamp(nextFridayTime)
    const res = [
        now1, now2, now3, now4, now5, next1, next2, next3, next4, next5
    ]
    return res
}

export default getTime;
